<?php

namespace app\admin\controller;

use think\Controller;
use think\Request;
use think\Db;
use think\Validate;
use app\admin\controller\Base;

class Mate extends Base
{
  public function index()
  {

    // return 000000000000000;die;
    $pgdata = Db::name('classmate_selecttip')->order('id')->paginate(6,true);
    $page = $pgdata->render();
    $data = $pgdata->all();
    
    // dump($data);die;

    return view('mate/mate',['title'=>'论坛列表','data'=>$data,'page'=>$page]);
  }
  public function forbid()
  {

      $id = input('post.');
      // return  $id['id'];
      // return  1000000;
      // 
      //查询现在的状态
      $res = Db::name('classmate_selecttip')->where('id',$id['id'])->find();

      if ($res['state'] == 1){
        $arr = ['state'=>2];
        $data = Db::name('classmate_selecttip')->where('id',$id['id'])->update($arr);
        return 2;
      }else{
        $arr = ['state'=>1];
        $data = Db::name('classmate_selecttip')->where('id',$id['id'])->update($arr);
        return 1;
      }

      

  		 
  }
}
